import 'package:flutter/material.dart';
import 'package:ycbl/config/bl_color.dart';

import 'image.dart';

/// 圆形头像
class BLRoundAvatar extends StatelessWidget {

  final double size;
  final String url;
  final Color borderColor;

  const BLRoundAvatar({
    Key key,
    @required this.size,
    @required this.url,
    this.borderColor = BLColor.commonBgColor
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: size,
      height: size,
      child: ClipOval(
        child: Container(
          //背景色
          decoration: BoxDecoration(
            color: borderColor,
          ),
          //圆形边框
          foregroundDecoration: BoxDecoration(
              border: Border.all( color: borderColor),
              borderRadius: BorderRadius.all(Radius.circular(size),),
          ),
          padding: EdgeInsets.all(1), //这一像素是 border 的宽度
          child: BLNetworkImage(url: url, fit: BoxFit.fitHeight,),
        ),
      ),
    );
  }
}
